package durak;

import FrenchCards.FrenchCardInfo;

public class DurakRule {

	static public boolean canDefend(DurakCard aAttack, DurakCard aDefend, DurakTable aTable) {
		FrenchCardInfo attackInfo = aAttack.getInfo();
		FrenchCardInfo defendInfo = aDefend.getInfo();

		if (attackInfo.suit == defendInfo.suit) {
			if (defendInfo.rank.compareTo(attackInfo.rank) > 0)
				return true;
		} else if (defendInfo.suit == aTable.getDeck().mTrumpSuit) {
			return true;
		}
		return false;
	}
	
	static public boolean canAttack(DurakCard aBy, DurakTable aTable){
		
		if (aTable.getCardsInGame().isEmpty())
			return true;
		
		for (DurakCard cardInGame : aTable.getCardsInGame())
			if(cardInGame.getInfo().rank == aBy.getInfo().rank)
				return true;
		
		return false;
	}
}
